﻿using System;
using System . Collections . Generic;
using System . Linq;
using System . Text;
using System . Threading . Tasks;

namespace WenceyWang . RichMan4L . Banks
{
	/// <summary>
	/// 银行的凭据
	/// </summary>
	public abstract class BankProof : GameObject
	{
		/// <summary>
		/// 凭据的开始日期
		/// </summary>
		public Calendars . GameDate StartDate { get; set; }

		/// <summary>
		/// 凭据的结束日期
		/// </summary>
		public Calendars . GameDate EndDate { get; set; }

		/// <summary>
		/// 凭据持续的时间
		/// </summary>
		public long DueTime { get { return EndDate - StartDate; } }

		/// <summary>
		/// 凭据的所有者
		/// </summary>
		public Players . Player Owner { get; set; }

	}

	/// <summary>
	/// 贷款凭据
	/// </summary>
	public class BorrowingBankProof : BankProof
	{
		/// <summary>
		/// 借出的款项数目
		/// </summary>
		public long MoneyBorrowed { get; set; }

		/// <summary>
		/// 利息率
		/// </summary>
		public double InterestRate { get; set; }

		/// <summary>
		/// 要归还的金额
		/// </summary>
		public long MoneyToReturn
		{
			get
			{
				return Convert . ToInt64 ( MoneyBorrowed * ( 1 + InterestRate ) );
			}
		}

		public override void StartDay ( Calendars . GameDate nextDate )
		{
			if ( nextDate >= EndDate )
			{

			}
		}

		public override void EndToday ( )
		{
			throw new NotImplementedException ( );
		}
	}

	/// <summary>
	/// 存款凭据
	/// </summary>
	public class SavingBankProof : BankProof
	{
		/// <summary>
		/// 存款数额
		/// </summary>
		public long MoneySaved { get; set; }

		/// <summary>
		/// 利息率
		/// </summary>
		public double InterestRate { get; set; }

		/// <summary>
		/// 能够取出的金额
		/// </summary>
		public long MoneyToGet
		{
			get
			{
				if ( Game . Current . Calendar . Today >= EndDate )
				{
					return Convert . ToInt64 ( MoneySaved * ( 1 + InterestRate ) );
				}
				else
				{
					return MoneySaved;
				}
			}
		}

		/// <summary>
		/// 
		/// </summary>
		public override void StartDay ( Calendars . GameDate nextDate )
		{
			if ( nextDate >= EndDate )
			{
				Owner . GetFromSaving ( this );
			}
		}

		public override void EndToday ( )
		{
			throw new NotImplementedException ( );
		}
	}



}
